﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MulticastTV
{
    public partial class Password : Form
    {

        Check Correct = new Check(false);
        Point Position;
        public Password(Check correct, Point loc)
        {
            InitializeComponent();
            Correct = correct;
            Position = loc;
        }

        private void Password_Load(object sender, EventArgs e)
        {
            this.Location = Position;
        }
        //ok
        private void button1_Click(object sender, EventArgs e)
        {
            check();
                       
        }
        //cancel
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Password_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                this.Close();
            }
            if (e.KeyCode == Keys.Enter)
            {
                check();
            }
        }

        private void maskedTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                check();
            }
            else if (e.KeyCode == Keys.Escape)
            {
                this.Close();
            }
        }

        private void check()
        {
            if (maskedTextBox1.Text == PasswordEncription.Password)
            {
                Correct.correct = true;
                label2.Visible = false;
                this.Close();
            }
            else
            {
                label2.Visible = true;
                Correct.correct = false;
            }
        }

    }
}
